home *** CD-ROM | disk | FTP | other *** search
/ Enigma Amiga Life 109 / EnigmaAmiga109CD.iso / dalla rivista / amiga.free / sorgenti vari / wolfedit2 2.0.4 source.sit / WolfEdit2 2.0.4 Source / UExtension.p < prev    next >
Text File  |  1995-04-02  |  1KB  |  71 lines

  1. unit UExtension;
  2.  
  3. interface
  4.  
  5.     procedure LoadExtensions;
  6.  
  7. implementation
  8.  
  9.     const
  10.  
  11.         extensionFileType = 'W3E2';
  12.         couldntLoadExtensionAlrtID = 139;
  13.         extensionLoadedAlrtID = 140;
  14.         loadExtensionAlrtID = 141;
  15.  
  16.     function ExtensionsDisabled: boolean;
  17.         var
  18.             e: EventRecord;
  19.     begin
  20.         if GetNextEvent(0, e) then
  21.             ;
  22.         ExtensionsDisabled := BAND(e.modifiers, shiftKey) <> 0;
  23.     end;
  24.  
  25.     procedure LoadExtensions;
  26.         var
  27.             pb: CInfoPBRec;
  28.             name: Str255;
  29.             refNum: integer;
  30.             i: integer;
  31.  
  32.         procedure Check (result: OSErr);
  33.             var
  34.                 item: integer;
  35.         begin
  36.             ParamText(name, StringOf(result : 1), '', '');
  37.             if result = noErr then
  38.         {item := Alert(extensionLoadedAlrtID, nil)}
  39.             else
  40.                 item := Alert(couldntLoadExtensionAlrtID, nil);
  41.         end;
  42.  
  43.         function GetCatInfo (i: integer): boolean;
  44.         begin
  45.             with pb do begin
  46.                     ioCompletion := nil;
  47.                     ioNamePtr := @name;
  48.                     ioVRefNum := 0;
  49.                     ioFDirIndex := i;
  50.                     ioDirID := 0;
  51.                 end;
  52.             GetCatInfo := PBGetCatInfo(@pb, false) = noErr;
  53.         end;
  54.  
  55.     begin {LoadExtensions}
  56.         if not ExtensionsDisabled then begin
  57.                 i := 1;
  58.                 while GetCatInfo(i) do begin
  59.                         if pb.ioFlFndrInfo.fdType = extensionFileType then begin
  60.                                 ParamText(name, '', '', '');
  61.                                 if Alert(loadExtensionAlrtID, nil) = ok then begin
  62.                                         refNum := OpenResFile(name);
  63.                                         Check(ResError);
  64.                                     end;
  65.                             end;
  66.                         i := i + 1;
  67.                     end;
  68.             end;
  69.     end;
  70.  
  71. end.